home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / mflm.rexx < prev    next >
OS/2 REXX Batch file  |  1993-04-14  |  5KB  |  205 lines

  1. /* ARexx MFLM */
  2. parse arg var1
  3. /*
  4.  * MFLM.rexx - MFLM image (a frame from WinImages:morph 24-bit filmstrip) load
  5.  *
  6.  * If you encounter  a .MFLM file we do not read, sent it to us (we suggest
  7.  * you use the Black Belt Bulletin Board at 1-406-367 2227) with an
  8.  * explanation and we will endeavor to extend our loader to handle it.
  9.  *
  10.  *  Written by: Black Belt Systems  Technical Development
  11.  * Last Update: March 25th, 1993
  12.  *    Revision: 1.01
  13.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  14.  *
  15.  * Modifications:
  16.  *        1.01  25 Mar 1993  (BC)  Did not report on insufficient memory for
  17.  *                                 new buffer from IM prior to 9.51
  18.  *        1.00  25 Feb 1993  (BC)  Initial release.
  19.  *
  20.  */
  21.  
  22. /*
  23.  * open rexxsupport.library -- needed for some functions
  24.  */
  25. if ~show('L',"rexxsupport.library") then do
  26.   if addlib('rexxsupport.library',0,-30,0) then do
  27.       /* everything's ok */
  28.     end;
  29.   else do
  30.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  31.     say 'Cannot operate script without this library - sorry!';
  32.     exit 10;
  33.     end;
  34.   end;
  35.  
  36. prtnme = 'IM_Port';
  37. cmdpath = 'cmpi:';
  38.  
  39. /*
  40.  * Get the file name parts
  41.  */
  42.   prevpath = 'ram:';
  43.   if show('C',rawpath) = 1 then do
  44.     prevpath = getclip(rawpath);
  45.     end;
  46.   prevname = 'image';
  47.   if show('C',rawname) = 1 then do
  48.     prevname = getclip(rawname);
  49.     end;
  50.   prevext = '.FLM';
  51.   if show('C',rawext) = 1 then do
  52.     prevext = getclip(rawext);
  53.     end;
  54.  
  55. address(prtnme);
  56. 'autoredraw 0';
  57.  
  58. if var1 = 'load' then do
  59.   loadquestion = 0
  60.   end
  61. else if var1 = 'save' then do
  62.   loadquestion = 1
  63.   end
  64. else do
  65.   options results;
  66.   'gadgets "Load .MFLM","Image","Save .MFLM","Image"';
  67.   loadquestion = result-1;
  68.   options;
  69.   end
  70.  
  71. if loadquestion < 0 then do
  72.   address(prtnme);
  73.   'tofront';
  74.   exit 0;
  75.   end
  76.  
  77. if loadquestion = 0 then do
  78.   options results;
  79.   'filerequest "'||prevpath||'" "'||prevname||'" "'||prevext||'" '||'"Load .MFLM"';
  80.   MFLMfile = result;
  81.   options;
  82.   call checkfile(MFLMfile);
  83.   end
  84. if loadquestion = 1 then do
  85.   options results;
  86.   'filerequest "'||prevpath||'" "'||prevname||'" "'||prevext||'" '||'"Save .MFLM"';
  87.   MFLMfile = result;
  88.   options;
  89.   call checkfile(MFLMfile);
  90.   
  91.   /* Could put compression question Here !! */
  92.   
  93.   end
  94.     
  95.     options results;
  96.     'jackin';
  97.     jack = result;
  98.     options;
  99.  
  100.     address command cmdpath||'MFLM '||jack||' '||loadquestion||' "'||MFLMfile||'" '||prevname||' '||compression;
  101.     address(prtnme);
  102.  
  103. 'autoredraw 1';
  104.  
  105. exit 0;
  106.  
  107.  
  108.  
  109.  
  110. checkfile: 
  111. arg thefile;
  112.   if thefile = 'FR_CANCELLED' then do
  113.     address(prtnme);
  114.     'tofront';
  115.     exit 0;
  116.     end;
  117.   prevpath = gimmepath(thefile);
  118.   call setclip(rawpath,prevpath);
  119.   prevname = gimmename(thefile);
  120.   call setclip(rawname,prevname);
  121.   prevext  = gimmeext(thefile);
  122.   call setclip(rawext,prevext);
  123.   return;
  124.   end
  125.  
  126. /*
  127.  * gimmepath
  128.  *
  129.  * This takes the provided argument and sucks the path out of it, then
  130.  * returns that path to the caller, sans file name.
  131.  */
  132. gimmepath:
  133.   arg fullnamegx;
  134.     tempgx = reverse(fullnamegx);
  135.     lengx = length(fullnamegx);   /* get length of string */
  136.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  137.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  138.     seploc = 0; /* assumes current dir, no path supplied */
  139.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  140.       seploc = (lengx - slashdex)+1;
  141.       end;
  142.     else do
  143.       if colondex ~= 0 then do /* we assume we are on a device */
  144.         seploc = (lengx - colondex)+1;
  145.         end;
  146.       end;
  147.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  148.   gxpath = left(fullnamegx,seploc);
  149.   return(gxpath);
  150.   end
  151.  
  152.  
  153. gimmename:
  154.   arg fullnamegx;
  155.     tempgx = reverse(fullnamegx);
  156.     lengx = length(fullnamegx);   /* get length of string */
  157.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  158.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  159.     seploc = 0; /* assumes current dir, no path supplied */
  160.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  161.       seploc = (lengx - slashdex)+1;
  162.       end;
  163.     else do
  164.       if colondex ~= 0 then do /* we assume we are on a device */
  165.         seploc = (lengx - colondex)+1;
  166.         end;
  167.       end;
  168.   extpos = lastpos(".",fullnamegx) - 2;
  169.   if extpos > seploc then do
  170.     gxname = substr(fullnamegx,seploc+1,extpos-seploc+1);
  171.     end;
  172.   else do
  173.     gxname = substr(fullnamegx,seploc+1);
  174.     end;
  175.   return(gxname);
  176.   end
  177.  
  178.  
  179. gimmeext:
  180.   arg fullnamegx;
  181.     tempgx = reverse(fullnamegx);
  182.     lengx = length(fullnamegx);   /* get length of string */
  183.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  184.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  185.     seploc = 0; /* assumes current dir, no path supplied */
  186.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  187.       seploc = (lengx - slashdex)+1;
  188.       end;
  189.     else do
  190.       if colondex ~= 0 then do /* we assume we are on a device */
  191.         seploc = (lengx - colondex)+1;
  192.         end;
  193.       end;
  194.   extpos = lastpos(fullnamegx,'.');
  195.   if extpos > seploc then do
  196.     gxext = substr(fullnamegx,extpos+1);
  197.     end
  198.   else do
  199.     gxext = '';
  200.     end
  201.   return(gxext);
  202.   end
  203.  
  204.  
  205.